<template>
	
	<view class="wrap">
		<view class="search"><u-search v-model="keywords" @custom="search" @search="search" @clear="clear"></u-search></view>
		<scroll-view class="scroll-list" scroll-y="true" @scrolltolower="loadMore">
			<u-cell-group class="list" :border="false">
				<u-swipe-action v-for="(item, index) in list" :key="index" :index="index"style="border-bottom: 1px solid #ededed">
					<u-cell-item :arrow="true" @click="navTo(item.id, index)" >
						<text slot="title">{{ item.taskTitle || item.id }}</text>

						<view slot="label" style="padding-bottom:20rpx">任务类型：{{ item.taskTypeName }}</view>
					</u-cell-item>
				</u-swipe-action>
			</u-cell-group>
			
			<view class="loadmore" @click="loadMore"><u-loadmore :status="loadStatus"></u-loadmore></view>
		</scroll-view>
	</view>
</template>
<script>
/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
export default {
	data() {
		return {
			keywords: '',
			query: {
				pageNo: 1,
				pageSize: 20,
				orderBy: '',
				taskTypeCode: '',
				taskTitle: '',
				taskYear: new Date().getFullYear()
			},
			list: [],
			count: 0,
			loadStatus: 'loadmore',
			options: [{ text: '删除', style: { background: '#dd524d' } }]
		};
	},
	onLoad(op) {
			uni.setNavigationBarTitle({
				title: '任务部署审核'
			});
		this.loadList();
	},
	created() {
		
	},
	onShow() {
		if (uni.getStorageSync('refreshList') === true) {
			uni.removeStorageSync('refreshList');
			this.search('');
		}
	},
	methods: {
		loadMore() {
			this.loadStatus = 'loading';
			setTimeout(() => {
				this.query.pageNo += 1;
				this.loadList();
			}, 100);
		},
		loadList() {
				this.query.audicCode =this.vuex_user.userCode
				this.$u.api.taskInfo.sh(this.query).then(res => {
					if (!res.list || res.list.length == 0) {
						this.loadStatus = 'nomore';
						return;
					}
					this.list = this.list.concat(res.list);
					this.count = res.count;
					this.query.pageNo = res.pageNo;
					this.query.pageSize = res.pageSize;
					this.loadStatus = 'loadmore';
				});
			
		},
		search(value) {
			this.list = [];
			this.query.pageNo = 0;
			this.query.taskTitle = value;
			this.loadList();
		},
		clear() {
			this.list = [];
			this.query.pageNo = 0;
			this.query.taskTitle = '';
			this.loadList();
		},
		navTo(url, index) {
			uni.navigateTo({
				url: './taskAuditForm?id=' + url
			});
			
		}
	}
};
</script>
<style lang="scss">
page {
	background-color: #f8f8f8;
}
.btn-plus {
	position: absolute;
	bottom: 50rpx;
	right: 50rpx;
	z-index: 1;
	opacity: 0.6;
}
.btn-plus:hover {
	opacity: 1;
}
// .u-cell{
// 	    display: block!important;
// }
</style>
